import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2025-01-26
 * Time: 14:20
 */
class Solution4 {
    public int firstUniqChar(String s) {
        int n = s.length();
        Map<Character,Integer> map = new HashMap<>();
        for(int i = 0 ; i < n  ; i++){
            char ch = s.charAt(i);
            map.put(ch , map.getOrDefault(ch,0) + 1);
        }

        for(int i = 0 ; i < n ; i++){
            int nums = map.get(s.charAt(i));
            if(nums == 1){
                return i;
            }
        }
        return -1;
    }
}
public class Test4 {
}
